export const removeNull = (data) => {
  const getValue = obj => {
    let newObj = {}
    for (let key in obj) {
      if (obj[key] !== null) {
        if (obj[key].constructor === Object) {
          newObj[key] = getValue(obj[key])
        } else {
          newObj[key] = obj[key]
        }
      }
    }
    return newObj
  }

  return getValue(data)
}

export const getBaseURL = () => {
  let host = location.host
  if (/192\.168|localhost|127/.test(host)) {
    return 'http://localhost:8014/'
  } else if (/yfyld/.test(host)) {
    return location.protocol + '//veditor.yfyld.online/api'
  } else {
    return location.origin + '/api/'
  }
}
